/* eslint-disable */
import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
import { util, configure } from "protobufjs/minimal";
import * as Long from "long";
import { Observable } from "rxjs";

export const protobufPackage = "code";

export interface Empty {}

export interface IDRequest {
  ID: number;
}

export interface Problem {
  ID: number;
  name: string;
  categoryId: number;
  content: string;
  verifyCode: string;
}

export interface Problems {
  value: Problem[];
}

export interface Category {
  ID: number;
  name: string;
  problems: Problem[];
}

export interface Categories {
  value: Category[];
}

export interface Question {
  ID: number;
  userId: string;
  problemId: number;
  title: string;
  content: string;
  answers: Answer[];
}

export interface Answer {
  ID: number;
  userId: string;
  content: string;
  questionId: number;
}

export const CODE_PACKAGE_NAME = "code";

export interface CodeServiceClient {
  getProblem(request: IDRequest): Observable<Problem>;

  getCategories(request: Empty): Observable<Categories>;

  createProblem(request: Problem): Observable<Problem>;

  createCategory(request: Category): Observable<Category>;

  createQuestion(request: Question): Observable<Question>;

  createAnswer(request: Answer): Observable<Answer>;

  removeQuestion(request: IDRequest): Observable<Empty>;

  removeCategory(request: IDRequest): Observable<Empty>;

  removeProblem(request: IDRequest): Observable<Empty>;

  removeAnswer(request: IDRequest): Observable<Empty>;
}

export interface CodeServiceController {
  getProblem(
    request: IDRequest
  ): Promise<Problem> | Observable<Problem> | Problem;

  getCategories(
    request: Empty
  ): Promise<Categories> | Observable<Categories> | Categories;

  createProblem(
    request: Problem
  ): Promise<Problem> | Observable<Problem> | Problem;

  createCategory(
    request: Category
  ): Promise<Category> | Observable<Category> | Category;

  createQuestion(
    request: Question
  ): Promise<Question> | Observable<Question> | Question;

  createAnswer(request: Answer): Promise<Answer> | Observable<Answer> | Answer;

  removeQuestion(
    request: IDRequest
  ): Promise<Empty> | Observable<Empty> | Empty;

  removeCategory(
    request: IDRequest
  ): Promise<Empty> | Observable<Empty> | Empty;

  removeProblem(request: IDRequest): Promise<Empty> | Observable<Empty> | Empty;

  removeAnswer(request: IDRequest): Promise<Empty> | Observable<Empty> | Empty;
}

export function CodeServiceControllerMethods() {
  return function (constructor: Function) {
    const grpcMethods: string[] = [
      "getProblem",
      "getCategories",
      "createProblem",
      "createCategory",
      "createQuestion",
      "createAnswer",
      "removeQuestion",
      "removeCategory",
      "removeProblem",
      "removeAnswer",
    ];
    for (const method of grpcMethods) {
      const descriptor: any = Reflect.getOwnPropertyDescriptor(
        constructor.prototype,
        method
      );
      GrpcMethod("CodeService", method)(
        constructor.prototype[method],
        method,
        descriptor
      );
    }
    const grpcStreamMethods: string[] = [];
    for (const method of grpcStreamMethods) {
      const descriptor: any = Reflect.getOwnPropertyDescriptor(
        constructor.prototype,
        method
      );
      GrpcStreamMethod("CodeService", method)(
        constructor.prototype[method],
        method,
        descriptor
      );
    }
  };
}

export const CODE_SERVICE_NAME = "CodeService";

// If you get a compile-error about 'Constructor<Long> and ... have no overlap',
// add '--ts_proto_opt=esModuleInterop=true' as a flag when calling 'protoc'.
if (util.Long !== Long) {
  util.Long = Long as any;
  configure();
}
